package com.justgame.project.service.api.dto;

import com.justgame.project.cloud.common.constant.ValidGroup;

import com.justgame.project.service.api.entity.SysUserInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;

/**
 * 用户注册提交信息模型
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SysUserInfoDTO extends SysUserInfo {
    /**
     * 登录或注册账号
     */
    @NotBlank(message = "账号不能为空！", groups = {ValidGroup.Select.class, ValidGroup.Add.class})
    @Length(max = 16, min = 8, message = "请输入8~16位账号！")
    private String account;

    /**
     * 登录或注册密码
     */
    @NotBlank(message = "密码不能为空！", groups = {ValidGroup.Select.class, ValidGroup.Add.class})
    @Length(max = 16, min = 8, message = "请输入8~16位密码！")
    private String password;

    /**
     * 短信验证码
     */
    private String smsCode;

    /**
     * 邮箱验证码
     */
    @NotBlank(message = "邮箱验证码不能为空！", groups = {ValidGroup.Add.class})
    @Length(min = 6, max = 6, message = "请输入6位邮箱验证码！")
    private String mailCode;


    public OnlineUserInfoDTO buildNewOnlineUser (){
        OnlineUserInfoDTO online = new OnlineUserInfoDTO();
        online.setUserId(this.getId());
        online.setOnlineId(this.getOnlineId());
        online.setOnlineName(this.getUname());
        online.setOnlineLevel(0);
        online.setFinalDate(null);
        online.setJCoins(5);
        online.setImages(null);
        online.setOnlineIntegral(0);
        online.setOnlineText("暂无相关简介。");
        return online;
    }
}
